package cn.zjq02.zuoye.One.fore;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;

public class Maptext {
    public static void main(String[] args) {
        Map<Integer,String> map = new HashMap<Integer, String>();
        map.put(1, "张三丰");
        map.put(2, "周芷若");
        map.put(3, "谢逊");
        map.put(4, "灭绝师太");

        Iterator<Map.Entry<Integer, String>> it = map.entrySet().iterator();
        while(it.hasNext()){
            Map.Entry<Integer, String> entry = it.next();
            System.out.println(entry.getKey()+"-"+entry.getValue());
        }
        System.out.println("----------------------");
        map.put(5,"李晓莉");
        map.remove(1);
        map.put(2,"周琳");
        Iterator<Map.Entry<Integer, String>> it2 = map.entrySet().iterator();
        while(it2.hasNext()){
            Map.Entry<Integer, String> entry = it2.next();
            System.out.println(entry.getKey()+"-"+entry.getValue());
        }

    }
}
